<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0px;
            margin: 0px;
        }
        .box1 {
            width: 200px;
            height: 100px;
            background: rgb(67, 73, 235);
             opacity: 0;  /*只是透明度隐藏，不会释放空间，还会触发事件 */
            /* visibility: hidden;  不会释放空间，不会触发事件,只会引起重绘*/
            /* display: none; 释放空间 */
            /* visibility: hidden; */
        }
        .box2 {
            width: 200px;
            height: 100px;
            background: rgb(244, 166, 50);
        }
    
    </style>
</head>
<body>
    <h1>隐藏页面中的某个元素</h1>
    <hr>
    <div class="box1"></div>
    <div class="box2"></div>
    <hr>

    <script>
        document.getElementsByClassName("box1")[0].onclick = function(){
           alert(111);
        }
    </script>
</body>
</html>